package com.jar.exercise.多线程.AQS.Synchronized;

public class Demo1 {
    public static void main(String[] args) {
        Phone phone = new Phone();
        Thread thread = new Thread(phone::call, "线程B");
        Thread thread1 = new Thread(phone::send, "线程A");

        thread.start();
        thread1.start();
    }
}

class Phone {
    public synchronized void call() {
        try {
            Thread.sleep(2000);
            System.out.println("打电话");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public synchronized void send() {
        System.out.println("发短信");
    }
}